package brave;

import org.bukkit.GameMode;
import org.bukkit.entity.Player;

public class WallPlayer
{
	private Player bukkitPlayer;
	
	private String name;
	private Integer gameId;
	private Integer teamId;
		
	private WallPlayerState state;
	
	public WallPlayer(String playerName, Player player)
	{
		this.state = WallPlayerState.DEFAULT;
		this.name = playerName;
		this.bukkitPlayer = player;
		this.gameId = null;
		this.teamId = null;
	}
	
	public WallPlayerState getState()
	{
		return this.state;
	}
	
	public void setState(WallPlayerState state)
	{
		this.state = state;
		
		// TODO: think about moving this else were
		//       pros. it keeps the state consistant
		//       cons. modifying too much in model
		//             also creates a less cohesive function
		switch (this.state)
		{
		case DEFAULT:
			this.gameId = null;
			this.teamId = null;
			this.bukkitPlayer.getInventory().clear();
			this.bukkitPlayer.setGameMode(GameMode.SURVIVAL);
			break;
		case IN_GAME:
			this.bukkitPlayer.setGameMode(GameMode.SURVIVAL);
			break;
		case OBSERVING_GAME:
			this.bukkitPlayer.setGameMode(GameMode.CREATIVE);
			this.bukkitPlayer.setFlying(true);
			break;
		}
	}
	
	public Player getBukkitPlayer()
	{
		return bukkitPlayer;
	}

	public void setBukkitPlayer(Player player)
	{
		this.bukkitPlayer = player;		
	}

	public String getName()
	{
		return name;
	}

	public Integer getGameId()
	{
		return this.gameId;
	}
	
	public void setGameId(Integer game)
	{
		this.gameId = game;
	}
	
	public Integer getTeamId()
	{
		return this.teamId;
	}
	
	public void setTeamId(Integer team)
	{
		this.teamId = team;
	}
}
